/*
 * Copyright 2009 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.splink.deepsplink.authentication {
	import org.splink.library.distributor.Devent;
	import org.splink.library.distributor.Dtype;
	import org.splink.library.distributor.IDistributor;

	/**
	 * An <code>AuthenticatorEvent</code> is distributed by an <code>IAuthenticator</code>
	 * implementation upon authentication completion.
	 * It can be either of the type <code>AuthenticatorEvent.SUCCESS</code> or 
	 * <code>AuthenticatorEvent.FAILURE</code>
	 * 
	 * @author Max Kugland
	 */
	public class AuthenticatorEvent extends Devent {
		public static const LOGIN_SUCCESS : Dtype = new Dtype("loginSuccess");
		public static const LOGIN_FAILURE : Dtype = new Dtype("loginFailure");
		public static const LOGOUT_SUCCESS : Dtype = new Dtype("logoutSuccess");
		private var _data : *;

		public function AuthenticatorEvent(source : IDistributor, type : Dtype, data : * = null) {
			super(source, type);
			_data = data;
		}

		/**
		 * @return a <code>AuthenticatorEvent</code> clone
		 */
		public function clone(source : IDistributor) : AuthenticatorEvent {
			return new AuthenticatorEvent(source, type, data);
		}

		/**
		 * @return the optional data
		 */
		public function get data() : * {
			return _data;
		}
	}
}
